// Copyright (c) 2022 Presto Labs Pte. Ltd.
// Author: fengyang

#pragma once

#include "coin2/exchange/base/feed/subscriber.h"

namespace coin2::exchange::base::feed::timer {
namespace impl {
using coin2::exchange::base::feed::FeedUpdate;
using coin2::feed::mgr::impl::FeedSubsystemManager;
class TimerManager;

class TimerFeedSubscriber : public exchange::base::feed::IFeedSubscriber {
 public:
  TimerFeedSubscriber(
      exchange::base::feed::IFeedSubscriber* subscriber,
      TimerManager* manager);
  void InjectFeed(const FeedSubsystemManager* feed_mgr) override;
  void onTradeFeed(const FeedUpdate& upd) override;
  void onLiquidationFeed(const FeedUpdate& upd) override;
  void onOpenInterestFeed(const FeedUpdate& upd) override;
  void onMarkPriceFeed(const FeedUpdate& upd) override;
  void onIndexFeed(const FeedUpdate& upd) override;
  void onFundingRateFeed(const FeedUpdate& upd) override;
  void onIvGreeksFeed(const FeedUpdate& upd) override;
  void onNavFeed(const FeedUpdate& upd) override;
  void onWalletFeed(const FeedUpdate& upd) override;
  void onMarketAnalysisFeed(const FeedUpdate& upd) override;
  void onTopLongShortAccountRatioFeed(const FeedUpdate& upd) override;
  void onTopLongShortPositionRatioFeed(const FeedUpdate& upd) override;
  void onGlobalLongShortAccountRatioFeed(const FeedUpdate& upd) override;
  void onTakerBuySellRatioFeed(const FeedUpdate& upd) override;
  void onOpenInterestHistFeed(const FeedUpdate& upd) override;
  void onBookFeed(const FeedUpdate& upd) override;
  void onKlineFeed(const FeedUpdate& upd) override;
  void onHeartbeatFeed(const FeedTimer& timer) override;

 private:
  void UpdateTimestamp(int64_t now);

  exchange::base::feed::IFeedSubscriber* subscriber_;
  TimerManager* manager_;
};

}  // namespace impl

using impl::FeedTimer;

}  // namespace coin2::exchange::base::feed::timer
